import request from '@/router/axios';

/**
 * 获取列表
 * @param current
 * @param size
 * @param params
 * @returns {*}
 */
export const getPayableList = (current, size, params) =>{
  return request({
    url: '/api/beetles-business/finance/payable/page',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}

/**
 * 新增/修改
 * @param data
 * @returns {*}
 */
export const addPayable = (financePayable, details) =>{
  return request({
    url:'/api/beetles-business/finance/payable/save',
    method:'post',
    timeout: 3600 * 1000,
    data: {
      financePayable: financePayable,
      details: details
    }
  })
}

/**
 * 删除
 * @param data
 * @returns {*}
 */
export const removePayable = (data) =>{
  return request({
    url:'/api/beetles-business/finance/payable/remove',
    method:'post',
    params:{
      ids:data
    }
  })
}

/**
 * 更新
 * @param data
 * @returns {*}
 */
export const updatePayable = (financePayable, details) =>{
  return request({
    url:'/api/beetles-business/finance/payable/update',
    method:'post',
    data: {
      financePayable: financePayable,
      details: details
    }
  })
}

export const downloadInvoice = (data) =>{
  return request({
    url:'/api/beetles-business/finance/payable/update',
    method:'post',
    data:data
  })
}

export const getFinanceEntityList = (customerId) => {
  return request({
    url: '/api/beetles-business/finance/invoiceEntity/list',
    method: 'get',
    params: {
      customerId
    }
  })
}

export const changePayableStatus = data =>{
  return request({
    url: '/api/beetles-business/finance/payable/changeStatus',
    method: "post",
    data:{...data}
  })
}

export const getPayableCustomers = () =>{
  return request({
    url: '/api/beetles-business/finance/payable/payable-customer',
    method: "get",
  })
}

export const exportExcel3 = (ids) => {
  return request({
    url: '/api/beetles-business/finance/payable/export',
    method: "get",
    params:ids,
    responseType: 'blob',
    // headers: {
    //   'Content-Type': 'application/x-www-form-urlencoded'
    // },
    // responseType: 'blob'
  })
}

//批量修改状态
export const batchChangeStatus = data => {
  return request({
    url: '/api/beetles-business/finance/payable/batchChangeStatus',
    method: 'post',
    data:data
  })
}
